package lab03.test01;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * Created by AIR on 2017/11/16.
 */

public class Test {
    public static void main(String[] args) {
//1.写文件，通过java写一个程序实现在D盘里边建一个文本文档，并写上一些文字
        String path="D:\\hello.txt";//路径
        BufferedWriter writer=null;

        //字符流
        try{
            writer = new BufferedWriter(new FileWriter(path));

            writer.write("hello.world!");
            writer.newLine();//换行

            writer.write("程嘉星");
            writer.newLine();

            writer.write("come on!");

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
               writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
